.class Lcom/glympse/platform/Platform$SmsBroadcastReceiver;
.super Landroid/content/BroadcastReceiver;
.source "Platform.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/glympse/platform/Platform;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x2
    name = "SmsBroadcastReceiver"
.end annotation


# static fields
.field private static final SMS_DELIVERED:Ljava/lang/String; = "com.glympse.android.glympse.SMS_DELIVERED"

.field private static final SMS_SENT:Ljava/lang/String; = "com.glympse.android.glympse.SMS_SENT"


# instance fields
.field private m_fUseDelivered:Z

.field private m_oRecipient:Lcom/glympse/platform/common/Recipient;

.field final synthetic this$0:Lcom/glympse/platform/Platform;


# direct methods
.method public constructor <init>(Lcom/glympse/platform/Platform;Lcom/glympse/platform/common/Recipient;Ljava/lang/String;Ljava/lang/String;)V
    .locals 2
    .parameter
    .parameter "oRecipient"
    .parameter "strActionSent"
    .parameter "strActionDelivered"

    .prologue
    .line 1322
    iput-object p1, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->this$0:Lcom/glympse/platform/Platform;

    .line 1310
    invoke-direct {p0}, Landroid/content/BroadcastReceiver;-><init>()V

    .line 1306
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->m_oRecipient:Lcom/glympse/platform/common/Recipient;

    .line 1307
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->m_fUseDelivered:Z

    .line 1312
    iput-object p2, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->m_oRecipient:Lcom/glympse/platform/common/Recipient;

    .line 1313
    sget-object v0, Lcom/glympse/platform/Platform;->m_oContext:Landroid/content/Context;

    if-eqz v0, :cond_0

    .line 1315
    sget-object v0, Lcom/glympse/platform/Platform;->m_oContext:Landroid/content/Context;

    new-instance v1, Landroid/content/IntentFilter;

    invoke-direct {v1, p3}, Landroid/content/IntentFilter;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0, p0, v1}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    .line 1316
    if-eqz p4, :cond_0

    .line 1318
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->m_fUseDelivered:Z

    .line 1319
    sget-object v0, Lcom/glympse/platform/Platform;->m_oContext:Landroid/content/Context;

    new-instance v1, Landroid/content/IntentFilter;

    invoke-direct {v1, p4}, Landroid/content/IntentFilter;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0, p0, v1}, Landroid/content/Context;->registerReceiver(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;

    :cond_0
    return-void
.end method

.method private Stop()V
    .locals 1

    .prologue
    .line 1327
    sget-object v0, Lcom/glympse/platform/Platform;->m_oContext:Landroid/content/Context;

    if-eqz v0, :cond_0

    .line 1329
    sget-object v0, Lcom/glympse/platform/Platform;->m_oContext:Landroid/content/Context;

    invoke-virtual {v0, p0}, Landroid/content/Context;->unregisterReceiver(Landroid/content/BroadcastReceiver;)V

    .line 1331
    :cond_0
    return-void
.end method


# virtual methods
.method public onReceive(Landroid/content/Context;Landroid/content/Intent;)V
    .locals 11
    .parameter "oContext"
    .parameter "oIntent"

    .prologue
    .line 1354
    const/4 v0, 0x1

    .line 1355
    .local v0, RESULT_ERROR_GENERIC_FAILURE:I
    const/4 v3, 0x2

    .line 1356
    .local v3, RESULT_ERROR_RADIO_OFF:I
    const/4 v2, 0x3

    .line 1357
    .local v2, RESULT_ERROR_NULL_PDU:I
    const/4 v1, 0x4

    .line 1360
    .local v1, RESULT_ERROR_NO_SERVICE:I
    const/4 v8, 0x0

    .line 1361
    .local v8, strResult:Ljava/lang/String;
    const/4 v6, 0x0

    .line 1362
    .local v6, nErrorCode:I
    const/4 v7, 0x0

    .line 1364
    .local v7, nResult:I
    invoke-virtual {p0}, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->getResultCode()I

    move-result v9

    packed-switch v9, :pswitch_data_0

    .line 1391
    :pswitch_0
    const-string v8, "Unknown error"

    .line 1392
    invoke-virtual {p0}, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->getResultCode()I

    move-result v6

    .line 1393
    if-lez v6, :cond_5

    move v7, v6

    .line 1398
    :goto_0
    :pswitch_1
    if-eqz v8, :cond_0

    if-eqz v6, :cond_0

    .line 1400
    new-instance v9, Ljava/lang/StringBuilder;

    invoke-static {v8}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v10

    invoke-direct {v9, v10}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v10, " ("

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9, v6}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v9

    const-string v10, ")"

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v8

    .line 1403
    :cond_0
    new-instance v9, Ljava/lang/StringBuilder;

    invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;

    move-result-object v10

    invoke-static {v10}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v10

    invoke-direct {v9, v10}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v10, ", Result: "

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-static {v8}, Lcom/glympse/platform/common/Helpers;->SafeStr(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    const-string v10, ", Recipient.Hash: "

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v9

    iget-object v10, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->m_oRecipient:Lcom/glympse/platform/common/Recipient;

    invoke-virtual {v10}, Ljava/lang/Object;->hashCode()I

    move-result v10

    invoke-virtual {v9, v10}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v9

    invoke-virtual {v9}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v9

    invoke-static {v9}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/String;)V

    .line 1405
    const/4 v5, 0x0

    .line 1406
    .local v5, fSuccess:Z
    const/4 v4, 0x0

    .line 1409
    .local v4, fFailed:Z
    invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;

    move-result-object v9

    const-string v10, "com.glympse.android.glympse.SMS_SENT"

    invoke-virtual {v9, v10}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v9

    if-eqz v9, :cond_7

    .line 1412
    if-eqz v8, :cond_6

    .line 1414
    const/4 v4, 0x1

    .line 1441
    :cond_1
    :goto_1
    if-nez v5, :cond_2

    if-eqz v4, :cond_4

    .line 1444
    :cond_2
    const/4 v9, 0x3

    iget-object v10, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->m_oRecipient:Lcom/glympse/platform/common/Recipient;

    iget v10, v10, Lcom/glympse/platform/common/Recipient;->m_eSendState:I

    if-ne v9, v10, :cond_3

    .line 1447
    if-eqz v5, :cond_9

    .line 1449
    iget-object v9, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->m_oRecipient:Lcom/glympse/platform/common/Recipient;

    const/4 v10, 0x5

    iput v10, v9, Lcom/glympse/platform/common/Recipient;->m_eSendState:I

    .line 1459
    :goto_2
    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v9

    const/16 v10, 0x1000

    invoke-virtual {v9, v10}, Lcom/glympse/platform/Platform;->DoUpdate(I)V

    .line 1463
    :cond_3
    invoke-direct {p0}, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->Stop()V

    .line 1465
    :cond_4
    return-void

    .line 1370
    .end local v4           #fFailed:Z
    .end local v5           #fSuccess:Z
    :pswitch_2
    const-string v8, "General failure. The phone number may be invalid."

    .line 1371
    const/4 v7, 0x1

    .line 1372
    const-string v9, "errorCode"

    const/4 v10, 0x0

    invoke-virtual {p2, v9, v10}, Landroid/content/Intent;->getIntExtra(Ljava/lang/String;I)I

    move-result v6

    .line 1373
    goto/16 :goto_0

    .line 1376
    :pswitch_3
    const-string v8, "No SMS service"

    .line 1377
    const/4 v7, 0x4

    .line 1378
    goto/16 :goto_0

    .line 1381
    :pswitch_4
    const-string v8, "Invalid SMS message format"

    .line 1382
    const/4 v7, 0x3

    .line 1383
    goto/16 :goto_0

    .line 1386
    :pswitch_5
    const-string v8, "Radio is off. Are you in airplane mode?"

    .line 1387
    const/4 v7, 0x2

    .line 1388
    goto/16 :goto_0

    .line 1393
    :cond_5
    const/16 v9, 0x22b

    move v7, v9

    goto/16 :goto_0

    .line 1418
    .restart local v4       #fFailed:Z
    .restart local v5       #fSuccess:Z
    :cond_6
    iget-boolean v9, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->m_fUseDelivered:Z

    if-nez v9, :cond_1

    .line 1420
    const/4 v5, 0x1

    goto :goto_1

    .line 1425
    :cond_7
    invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;

    move-result-object v9

    const-string v10, "com.glympse.android.glympse.SMS_DELIVERED"

    invoke-virtual {v9, v10}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v9

    if-eqz v9, :cond_1

    .line 1428
    if-eqz v8, :cond_8

    .line 1430
    const/4 v4, 0x1

    goto :goto_1

    .line 1436
    :cond_8
    const/4 v5, 0x1

    goto :goto_1

    .line 1453
    :cond_9
    iget-object v9, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->m_oRecipient:Lcom/glympse/platform/common/Recipient;

    const/4 v10, 0x4

    iput v10, v9, Lcom/glympse/platform/common/Recipient;->m_eSendState:I

    .line 1454
    iget-object v9, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->m_oRecipient:Lcom/glympse/platform/common/Recipient;

    iput v7, v9, Lcom/glympse/platform/common/Recipient;->m_nResult:I

    .line 1455
    iget-object v9, p0, Lcom/glympse/platform/Platform$SmsBroadcastReceiver;->m_oRecipient:Lcom/glympse/platform/common/Recipient;

    iput-object v8, v9, Lcom/glympse/platform/common/Recipient;->m_strResult:Ljava/lang/String;

    goto :goto_2

    .line 1364
    :pswitch_data_0
    .packed-switch -0x1
        :pswitch_1
        :pswitch_0
        :pswitch_2
        :pswitch_5
        :pswitch_4
        :pswitch_3
    .end packed-switch
.end method
